package cn.edu.zafu.bigdata.hdb;
import java.util.HashMap;
class StudentGradeManager{
    //HashMap 存储学生姓名和成绩
    private HashMap<String, Integer> studentGrades;
    //构造初始化HashMap
    public StudentGradeManager(){
        studentGrades=new HashMap<>();
    }
    //添加学生成绩
    void addStudent(String name, int grade){
        studentGrades.put(name,grade);
    }
    //根据学生姓名来获取成绩
    int getGrade(String name){
        return studentGrades.getOrDefault(name,-1);
    }
    //删除学生成绩
    void removeStudent(String name){
        studentGrades.remove(name);
    }
}
public class TestStudentGradeManager {
    public static void main(String[] args){
        //创建学生成绩管理对象
        StudentGradeManager gradeManager=new StudentGradeManager();
        //添加学生成绩
        gradeManager.addStudent("hedebiao",96);
        gradeManager.addStudent("huyan",98);
        gradeManager.addStudent("huzeqi",97);
        gradeManager.addStudent("zhengbowen",99);
        //查询学生成绩
        System.out.println("hedebiao‘s grade:"+gradeManager.getGrade("hedebiao"));
        System.out.println("huyan’s grade:"+gradeManager.getGrade("huyan"));
        System.out.println("huzeqi‘s grade:"+gradeManager.getGrade("huzeqi"));
        System.out.println("zhengbowen’s grade:"+gradeManager.getGrade("zhengbowen"));
        //删除学生成绩
        gradeManager.removeStudent("hedebiao");
        System.out.println("hedebiao‘s grade after removal:"+gradeManager.getGrade("hedebiao"));
    }
}
